#include <graphics.h>
#include <conio.h>
#include <stdio.h>
#include <time.h>

int main()
{
	float PI = 3.14159;
	initgraph(1200, 800);
	setbkcolor(RGB(128, 128, 128));
	cleardevice();
	srand(time(0));

	int centerX;
	int centerY;
	int radius;
	int i;
	float offset;
	float totaloffset = 0;
	int left;
	int top;
	int right;
	int bottom;
	float h;

	while (1)
	{
		for (centerX = 200; centerX < 1200; centerX = centerX + 400)
		{
			for (centerY = 200; centerY < 800; centerY = centerY + 400)
			{
				h = rand() % 180;
				COLORREF color1 = HSVtoRGB(h, 0.9, 0.8);
				COLORREF color2 = HSVtoRGB(h + 180, 0.9, 0.8);

				for (radius = 200; radius > 0; radius = radius - 40)
				{
					left = centerX - radius;
					top = centerY - radius;
					right = centerX + radius;
					bottom = centerY + radius;

					for (i = 0; i < 20; i++)
					{
						offset = i * PI / 10 + totaloffset;
						setfillcolor(color1);
						solidpie(left, top, right, bottom, offset, 2 * PI / 60 + offset);
						setfillcolor(RGB(255, 255, 255));
						solidpie(left, top, right, bottom, 2 * PI / 60 + offset, 3 * PI / 60 + offset);
						setfillcolor(color2);
						solidpie(left, top, right, bottom, 3 * PI / 60 + offset, 5 * PI / 60 + offset);
						setfillcolor(RGB(0, 0, 0));
						solidpie(left, top, right, bottom, 5 * PI / 60 + offset, 6 * PI / 60 + offset);
					}
					totaloffset = totaloffset + PI / 20;
				}
			}
		}
		_getch();
	}

	return 0;
}